<?php


namespace App\Admin\Controllers\Owner;


use Carbon\Carbon;
use Dcat\Admin\Grid;
use Dcat\Admin\IFrameGrid;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Widgets\Alert;

class LeaseExpiresController extends CommonOwnerController
{
    protected $title = "租约即将到期的租客";

    public function index(Content $content)
    {
        if (request(IFrameGrid::QUERY_NAME)) {
            return $content->perfectScrollbar()->body($this->iFrameGrid());
        }

        $info = '<i class="fa fa-exclamation-circle"></i> 默认获取租约还剩30到期的租客';

        return $content
            ->title($this->title())
            ->description($this->description()['index'] ?? trans('admin.list'))
            ->body(Alert::make($info)->info())
            ->body($this->grid());
    }

    protected function map(): array
    {
        return [
            ['ended_at', '<', Carbon::now()->addDays(30)],
            ['ended_at', '>', Carbon::now()]
        ];
    }

    protected function customGrid(Grid $grid)
    {
        // TODO: Implement customGrid() method.
    }

    protected function customDetail($show)
    {
        // TODO: Implement customDetail() method.
    }
}
